import { Injectable } from '@angular/core';
import {HttpClient, HttpHeaders, HttpResponse} from '@angular/common/http';
import { catchError, map, tap } from 'rxjs/operators';
import { Observable, of } from 'rxjs';
import {User} from '../models/user';
import {CommonUrl} from '../services/common/common-url';
import {HttpUtilService} from '../services/common/http-util.service';
import {HttpParams} from '@angular/common/http/src/params';


const httpOptions = {
  headers: new HttpHeaders({
    'Content-Type':  'application/json'
  })
};

@Injectable({
  providedIn: 'root'
})
export class LoginService {
  constructor(
    private http: HttpClient,
    private httpUtilService: HttpUtilService) { }

   login(user: User): Observable<any> {
    const url = CommonUrl.HOST + CommonUrl.LOGIN_URI + '?username=' + user.username + '&password=' + user.password;
    return this.http.post(url, '' , {responseType: 'text'});
  }
}
